<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<base href="<%=basePath%>">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>正文分词</title>
		<jsp:include page="loginUser.jsp" flush="true"/>
		
		<!-- jquery -->
		<jsp:include page="/pages/basic/jquery-loder.jsp" flush="true"/>
		
		<script type="text/javascript">
		
			/**
			 * 通过url返回正文
			 */
    		function getContent(){
    			var url = document.getElementById("url").value;
    			var params = {url:url};
    			$.ajax({
					type : "POST",
					dataType : "text",
					url: "contentAction_getUrlContent",
					data: params,
					success : function(dataText){
						document.getElementById("content").innerHTML = dataText;
					},
					error : function(XMLHttpRequest, textStatus,errorThrown){
						alert("网络连接失败");
					}
				});
    		}
    		
			/**
			 * 正文分词
			 */
    		function getKeyword(){
    			var content = document.getElementById("content").value;
    			var count = 6;
    			var params = {content: content,count: count};

    			$.ajax({
					type : "POST",
					dataType : "text",
					url: "contentAction_splitContent",
					data: params,
					success : function(dataText){
						document.getElementById("keyword").innerHTML = dataText;
					},
					error : function(XMLHttpRequest, textStatus,errorThrown){
						alert("网络连接失败");
					}
				});
    		}
			
			/**
			 * 过滤分词
			 */
			var filterWords = function(){
				var content = document.getElementById("content").value;
    			var count = 6;
    			var params = {content: content,count: count};

    			$.ajax({
					type : "POST",
					dataType : "text",
					url: "contentAction_filterSplitWords",
					data: params,
					success : function(dataText){
						document.getElementById("filterKeyword").innerHTML = dataText;
					},
					error : function(XMLHttpRequest, textStatus,errorThrown){
						alert("网络连接失败");
					}
				});
			}
			 
   		</script>
	</head>
	<body>
		<div>
			<table border="1" align="center" style="margin-top: 50px;" bordercolor="#cecece" cellpadding="0" cellspacing="0">
				<tr>
					<td width="100" align="right">请输入url：</td>
					<td width="500"><input type="text" id="url" value="http://hlj.sina.com.cn/news/b/2013-11-24/082280159.html" size="80"/></td>
					<td width="80" align="center"><input type="button" onclick="getContent();" value="获取正文"/></td>
				</tr>
				<tr>
					<td width="100" align="right">页面正文：</td>
					<td width="300" height="200">
						<textarea rows="20" cols="80" id="content"></textarea>
					</td>
					<td width="80" align="center">
						<input type="button" onclick="getKeyword();" value="正文分词"/>
					</td>
				</tr>
				<tr>
					<td colspan="2" height="200" width="480">
						<div id="keyword" style="font-size:13px;padding-left: 10px;padding-top: 10px"></div>
					</td>
					<td valign="bottom">
						<input type="button" value="过滤分词" onclick="filterWords();"/>
					</td>
				</tr>
				<tr>
					<td colspan="3" height="200" width="480">
						<div id="filterKeyword" style="font-size:13px;padding-left: 10px;padding-top: 10px"></div>
					</td>
				</tr>
			</table>
		</div>
		<br/><br/><br/><br/>
	</body>
</html>